package generation.makers;

import util.ConfigFile;
import util.Utils;

public class DurationMakerImpl implements DurationMaker {

	public static String[] generateOneLengthBeat(){
		String[] beat1 = {"q"};
		String[] beat2 = {"i", "i"};
		String[] beat3 = {"i*", "i*", "i*",};
		String[] beat4 = {"s", "s", "i"};
		String[] beat5 = {"i", "s", "s"};
		String[] beat6 = {"s", "i", "s"};
		String[] beat7 = {"s", "s", "s", "s"};
		String[][] beats;
		if(ConfigFile.getString("beat.cells").equals("only fast")){
			String[][] tempBeats = {beat4, beat5, beat6, beat7};
			beats = tempBeats;
		} else if(ConfigFile.getString("beat.cells").equals("only slow")){
			String[][] tempBeats = {beat1, beat2, beat3};
			beats = tempBeats;
		} else {
			String[][] tempBeats = {beat1, beat2, beat3, beat4, beat5, beat6, beat7};
			beats = tempBeats;
		}
		return beats[Utils.random(beats.length)];
	}

	public static String[] generateTwoLengthBeat(){
		String[] part1 = {"h"};
		String[] part2 = {"q*", "q*", "q*"};
		String[] aux = {"q"};
		String[] part3 = Utils.concatenateArrays(aux, generateOneLengthBeat());
		String[] part4 = Utils.concatenateArrays(generateOneLengthBeat(), aux);
		String[] part5 = Utils.concatenateArrays(generateOneLengthBeat(), generateOneLengthBeat());
		String[][] parts = {part1, part2, part3, part4, part5};
		return parts[Utils.random(parts.length)];
	}
	
	public static String[] generateFourLengthBeat(){
		String[] part1 = {"w"};
		String[] part2 = {"h*", "h*", "h*"};
		String[] aux = {"h"};
		String[] part3 = Utils.concatenateArrays(aux, generateTwoLengthBeat());
		String[] part4 = Utils.concatenateArrays(generateTwoLengthBeat(), aux);
		String[] part5 = Utils.concatenateArrays(generateTwoLengthBeat(), generateTwoLengthBeat());
		String[][] parts = {part1, part2, part3, part4, part5};
		return parts[Utils.random(parts.length)];
	}
	
	public static String[] generateChordsBeat(){
		String[] chordsBeats = {"w", "w", "w", "w"};
		return chordsBeats;
	}

}
